﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.MovieRecorder.CApMRCRecorderIndicatorViewModel
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.ComponentModel;
using System.Windows;
using System.Windows.Media;


namespace DnProcessSimulateCommands.MovieRecorder;

public class CApMRCRecorderIndicatorViewModel : INotifyPropertyChanged
{
  private static int BorderSegmentLength = 30;
  private static int BorderThickness = 6;
  private static int Offset = 4;
  private bool m_applyOffset;
  private PointCollection polyline1Points;
  private PointCollection polyline2Points;
  private PointCollection polyline3Points;
  private PointCollection polyline4Points;

  public Point TopLeft { get; set; }

  public Point BottomRight { get; set; }

  public CApMRCRecorderIndicatorViewModel(Point topLeft, Point bottomRight)
  {
    this.m_applyOffset = false;
    this.TopLeft = topLeft;
    this.BottomRight = bottomRight;
    this.polyline1Points = new PointCollection();
    this.polyline2Points = new PointCollection();
    this.polyline3Points = new PointCollection();
    this.polyline4Points = new PointCollection();
  }

  public PointCollection Line1Points => this.polyline1Points;

  public PointCollection Line2Points => this.polyline2Points;

  public PointCollection Line3Points => this.polyline3Points;

  public PointCollection Line4Points => this.polyline4Points;

  public int Thickness => CApMRCRecorderIndicatorViewModel.BorderThickness;

  public bool ApplyOffset
  {
    get => this.m_applyOffset;
    set
    {
      if (this.m_applyOffset == value)
        return;
      this.m_applyOffset = value;
      this.UpdateData();
    }
  }

  public void UpdateData()
  {
    Point point = this.TopLeft;
    double x1 = point.X - (this.ApplyOffset ? (double) CApMRCRecorderIndicatorViewModel.Offset : 0.0);
    point = this.TopLeft;
    double y1 = point.Y - (this.ApplyOffset ? (double) CApMRCRecorderIndicatorViewModel.Offset : 0.0);
    point = this.BottomRight;
    double x2 = point.X + (this.ApplyOffset ? (double) CApMRCRecorderIndicatorViewModel.Offset : 0.0);
    point = this.BottomRight;
    double y2 = point.Y + (this.ApplyOffset ? (double) CApMRCRecorderIndicatorViewModel.Offset : 0.0);
    this.polyline1Points = new PointCollection();
    this.polyline1Points.Add(new Point(x1, y1 + (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength));
    this.polyline1Points.Add(new Point(x1, y1));
    this.polyline1Points.Add(new Point(x1 + (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength, y1));
    this.polyline2Points = new PointCollection();
    this.polyline2Points.Add(new Point(x1, y2 - (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength));
    this.polyline2Points.Add(new Point(x1, y2));
    this.polyline2Points.Add(new Point(x1 + (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength, y2));
    this.polyline3Points = new PointCollection();
    this.polyline3Points.Add(new Point(x2 - (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength, y1));
    this.polyline3Points.Add(new Point(x2, y1));
    this.polyline3Points.Add(new Point(x2, y1 + (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength));
    this.polyline4Points = new PointCollection();
    this.polyline4Points.Add(new Point(x2 - (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength, y2));
    this.polyline4Points.Add(new Point(x2, y2));
    this.polyline4Points.Add(new Point(x2, y2 - (double) CApMRCRecorderIndicatorViewModel.BorderSegmentLength));
    this.OnPropertyChanged("Line1Points");
    this.OnPropertyChanged("Line2Points");
    this.OnPropertyChanged("Line3Points");
    this.OnPropertyChanged("Line4Points");
  }

  public event PropertyChangedEventHandler PropertyChanged;

  protected virtual void OnPropertyChanged(string propertyName)
  {
    if (this.PropertyChanged == null)
      return;
    this.PropertyChanged((object) this, new PropertyChangedEventArgs(propertyName));
  }
}
